//
//  NSString+LRExtend.m
//

#import "NSString+LRExtend.h"
#import <CommonCrypto/CommonDigest.h>

@implementation NSString (LRExtend)

-(CGSize)sizeWithFont:(UIFont*)font
{
    return [self sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil]];
}

-(CGSize)sizeWithFont:(UIFont*)font maxWidth:(CGFloat)maxWith
{
    return [self boundingRectWithSize:CGSizeMake(maxWith, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{
                                                                                                                               NSFontAttributeName:font                                                                } context:nil].size;
}


-(NSString *)toPingYing
{
    NSMutableString *pinyin = [self mutableCopy];
    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripCombiningMarks, NO);
    NSLog(@"%@", pinyin);
    return [pinyin uppercaseString];
}


@end
